
             
/**
 * 
 *
 * @File name:  AddTDepartmentAction.java   添加【部门信息:T_DEPARTMENT】
 * @Create on:  2011-10-30 19:25:171
 * @Author   :  陈伟
 *
 * @ChangeList
 * ---------------------------------------------------
 * Date         Editor              ChangeReasons
 *
 */
           
        
package com.boho.estates.department.action;

            
import java.sql.Connection;
import java.util.List;

import cn.boho.framework.actions.ActionImp;
import cn.boho.framework.context.ActionContext;
import cn.boho.framework.exception.UserOperationException;
import cn.boho.framework.po.DynaBeanMap;
import cn.boho.framework.po.POUtils;
import cn.boho.framework.service.MessageService;

import com.boho.common.Constant;
import com.boho.common.SystemUtils;
import com.boho.estates.po.TDepartmentPO;
import com.boho.estates.staff.dao.TPersonnalDao;

public class AddTDepartmentAction extends ActionImp {
	private TDepartmentPO tDepartmentPO = new TDepartmentPO();
	private Connection con=null;
	@Override
	protected void doException(ActionContext atx, Exception ex) {
		if (!(ex instanceof UserOperationException)) {
			atx.setErrorContext("BOHO_COMMON_1001", MessageService.getMessage("BOHO_COMMON_1001"),"【组织结构信息】", ex);
		}
	}
	@Override
	protected int performExecute(ActionContext atx) throws Exception {
		con = atx.getConection();
		StringBuffer sb = new StringBuffer();
		POUtils.insert(con, tDepartmentPO, false, sb);
		
		String departIds  = (String)atx.getSessionValue(Constant.SESSION_DEPART_ARRAY);
		departIds = departIds + "," + sb.toString();
		atx.setSessionValue(Constant.SESSION_DEPART_ARRAY, departIds);
		
		atx.setObjValue("ID", sb.toString());
		return 1;
	}
	@Override
	protected int verifyParameters(ActionContext atx) throws Exception {
		
		String createBy = SystemUtils.getSessionUser(atx);
		tDepartmentPO.setDepartmentName(atx.getStringValue("DEPARTMENT_NAME"));
		tDepartmentPO.setDepartmentPNo(atx.getIntegerValue("DEPARTMENT_PNO"));
		tDepartmentPO.setCreateDate(new java.util.Date());
		tDepartmentPO.setCreateBy(createBy);
		return 1;
	}
}
